/* GUI CONVERTED from ecdpldrp.p (converter v1.76) Thu Dec 20 07:31:02 2001 */
/* ecdpldrp.p - ECN DUMP / LOAD SUBROUTINE REPORT                             */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.9.1.6 $                                                      */
/*V8:ConvertMode=Report                                                       */
/* REVISION: 7.4      LAST EDIT: 04/20/94      MODIFIED BY: QZL *H358*        */
/* REVISION: 7.4      LAST EDIT: 08/26/94      MODIFIED BY: QZL *H489*        */
/* REVISION: 7.4      LAST EDIT: 10/27/94      MODIFIED BY: ame *H578*        */
/* REVISION: 7.4      LAST EDIT: 12/01/94      MODIFIED BY: QZL *H612*        */
/* REVISION: 7.4      LAST EDIT: 04/06/95      MODIFIED BY: AME *H0CF*        */
/* REVISION: 7.4      LAST EDIT: 12/29/95      MODIFIED BY: qzl *H0J1*        */
/* REVISION: 7.4      LAST EDIT: 08/01/96       BY: *H0M7* Russ Witt          */
/* REVISION: 7.4      LAST EDIT: 08/13/96       BY: *H0M8* Russ Witt          */
/* REVISION: 8.6      LAST EDIT: 12/05/96       BY: Joe Gawel *K00C*          */
/* REVISION: 8.6      LAST EDIT: 06/23/97       BY: Joe Gawel *K0FG*          */
/* REVISION: 8.6      LAST EDIT: 06/27/97       BY: Joe Gawel *K0F4*          */
/* REVISION: 8.6      LAST MODIFIED: 08/13/97   BY: Joe Gawel *K0H5*          */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 04/11/00   BY: *N08H* Vandna Rohira      */
/* REVISION: 9.1      LAST MODIFIED: 08/14/00   BY: *N0KW* Jacolyn Neder      */
/* $Revision: 1.9.1.6 $  BY: Jean Miller        DATE: 12/14/01  ECO: *P03Q*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdeclre.i}
{gplabel.i}

{ecrodef.i}  /* ECD2_DET SIDEFILE DEFINITIONS */

define input parameter dmpld like mfc_logical.
define input parameter dlfile as character format "x(46)" label "Dump/Load File".
define input parameter repro like mfc_logical.

define stream ecstream.

define new shared variable error_msg as character format "x(90)" extent 10.

define variable key_fld as character extent 5.
define variable i as integer.
define variable k as integer.
define variable filename as character format "x(8)".
define variable loadable like mfc_logical.
define variable ecmid   like wo_lot.
define variable dbase   like si_db.

define variable ecm_recid as recid.
define variable prog_type as character.
define variable msgnbr like msg_nbr.
define variable warnlvl as integer.
define variable keyfld as character format "x(80)".
define new shared variable yn like mfc_logical initial no.
define variable closed_yn like mfc_logical.
define variable ecmnbrto like ecm_nbr_to.
define variable mstrfile like mfc_logical.
define variable firsttime like mfc_logical initial yes.

define new shared workfile ecmmstr like ecm_mstr.
define new shared workfile ecd1det like ecd1_det.
define new shared workfile ecd2det like ecd2_det.
define new shared workfile ecd3det like ecd3_det.
define new shared workfile ecd4det like ecd4_det.

define new shared temp-table rsumstr like rsu_mstr.
define new shared temp-table rsuddet like rsud_det.

define new shared workfile ecddet  like ecd_det.
define new shared workfile cmtdet  like cmt_det.
define new shared workfile qadwkfl like qad_wkfl.

/* LOADING ERROR: PCC NUMBER EXISTS                       */
{pxmsg.i &MSGNUM=3571 &ERRORLEVEL=1 &MSGBUFFER=error_msg[1]}

/* LOADING ERROR: PCC TYPE DOES NOT EXIST                 */
{pxmsg.i &MSGNUM=3572 &ERRORLEVEL=1 &MSGBUFFER=error_msg[2]}

/* LOADING ERROR: PART MASTER DOES NOT EXIST              */
{pxmsg.i &MSGNUM=3569 &ERRORLEVEL=1 &MSGBUFFER=error_msg[3]}

/* LOADING ERROR: APPROVAL GROUP DOES NOT EXIST           */
{pxmsg.i &MSGNUM=3566 &ERRORLEVEL=1 &MSGBUFFER=error_msg[4]}

/* LOADING ERROR: GROUP DOES NOT EXIST WITH APPROVAL CODE */
{pxmsg.i &MSGNUM=3568 &ERRORLEVEL=1 &MSGBUFFER=error_msg[5]}

/* LOADING ERROR: PCC MASTER RECORD FAILED LOADING        */
{pxmsg.i &MSGNUM=3570 &ERRORLEVEL=1 &MSGBUFFER=error_msg[6]}

/* LOADING ERROR: COMMENT INDEX EXISTS                    */
{pxmsg.i &MSGNUM=3567 &ERRORLEVEL=1 &MSGBUFFER=error_msg[7]}

key_fld = "".
input stream ecstream from value(dlfile) no-map.

loop-b:

repeat for ecmmstr,ecd1det,ecd2det,ecd3det,ecd4det,rsumstr,rsuddet,
           ecddet, qadwkfl:

   import stream ecstream
      key_fld[1] key_fld[2] key_fld[3] key_fld[4] key_fld[5].

   if substring(key_fld[1],1,5) <> "type:" then next loop-b.

   if key_fld[1] = "type:ecm_mstr" or key_fld[1] = "" or
      key_fld[1] = "type:end of file"
   then do:

      find first ecmmstr no-error.
      if available ecmmstr then do:

         /*TEXT*/
         {gprun.i ""eciq11.p""
            "(input ecm_recid,
              input prog_type,
              input yes,
              input dmpld,
              input mstrfile,
              output msgnbr,
              output warnlvl)"}

         /*ITEMS*/
         {gprun.i ""eciq12.p""
            "(input ecm_recid,
              input prog_type,
              input yes,
              input dmpld,
              input mstrfile,
              output msgnbr,
              output warnlvl)"}

         /*STRUCTURES*/
         {gprun.i ""eciq13.p""
            "(input ecm_recid,
              input prog_type,
              input yes,
              input dmpld,
              input mstrfile,
              output msgnbr,
              output warnlvl)"}

         /*ROUTINGS*/
         {gprun.i ""eciq15.p""
            "(input ecm_recid,
              input prog_type,
              input yes,
              input dmpld,
              input mstrfile,
              output msgnbr,
              output warnlvl)"}

         /*APPROVALS*/
         {gprun.i ""eciq14.p""
            "(input ecm_recid,
              input prog_type,
              input yes,
              input dmpld,
              input mstrfile,
              input repro,
              output msgnbr,
              output warnlvl)"}

         ecm_recid = ?.

         for each ecmmstr exclusive-lock:
            delete ecmmstr.
         end.

         for each ecd1det exclusive-lock:
            delete ecd1det.
         end.

         for each qadwkfl exclusive-lock:
            delete qadwkfl.
         end.

         for each ecd2det exclusive-lock:
            delete ecd2det.
         end.

         for each ecd3det exclusive-lock:
            delete ecd3det.
         end.

         for each ecd4det exclusive-lock:
            delete ecd4det.
         end.

         for each rsumstr exclusive-lock:
            delete rsumstr.
         end.

         for each rsuddet exclusive-lock:
            delete rsuddet.
         end.

         for each cmtdet exclusive-lock:
            delete cmtdet.
         end.

         if key_fld[1] =  "type:end of file" then next loop-b.
         else if key_fld[1] = "" then return.

      end.

      if not firsttime then page.

      create ecmmstr.
      assign
         ecm_nbr = key_fld[2]
         ecm_type = key_fld[3]
         ecm_assign = key_fld[4].

      import stream ecstream ecmmstr
         except ecmmstr.ecm_nbr
                ecmmstr.ecm_type
                ecmmstr.ecm_assign.

      assign
         ecmid = substring(ecm_nbr,9,8)
         dbase = substring(ecm_nbr,17,8)
         ecm_recid = recid(ecmmstr).

      FORM /*GUI*/ 
         {ecform01.i}
      with STREAM-IO /*GUI*/  frame form01 attr-space side-labels width 80.

      /* SET EXTERNAL LABELS */
      setFrameLabels(frame form01:handle).

      display
         {ecform01.i}
      with frame form01 attr-space side-labels width 80 STREAM-IO /*GUI*/ .

      /*ECN TRAILER*/
      do on error undo, leave with frame form07:
         if ecm_close_date <> ? then
            closed_yn = yes.
         else
            closed_yn = no.
         /* SET EXTERNAL LABELS */
         setFrameLabels(frame form07:handle).
         display
            {ecform07.i}
         with frame form07 attr-space side-labels width 80 STREAM-IO /*GUI*/ .
      end.

      mstrfile = yes.

      if not dmpld then do:

         find ecm_mstr where ecm_mstr.ecm_nbr = ecmmstr.ecm_nbr
         no-lock no-error.

         keyfld = trim(ecmmstr.ecm_nbr).

         if available ecm_mstr then do:
            put error_msg[1].
            mstrfile = no.
         end.

         else
         if not available ecm_mstr and
            not repro and
            not can-find(pct_mstr where
                         pct_type = ecmmstr.ecm_type and
                         pct_dsgn_grp = ecmmstr.ecm_assign)
         then do:
            put error_msg[4].
            mstrfile = no.
         end.

      end.

      firsttime = no.

   end.

   else
   if substring(key_fld[1],1,13) = "type:ecd1_det"
   then do on error undo:

      create ecd1det.
      assign
         ecd1_nbr  = key_fld[2]
         ecd1_par  = key_fld[3]
         ecd1_comp = key_fld[4]
         ecd1_ref  = key_fld[5].

      import stream ecstream ecd1det except
         ecd1det.ecd1_nbr
         ecd1det.ecd1_par
         ecd1det.ecd1_comp
         ecd1det.ecd1_ref.

   end.

   else if key_fld[1] = "type:ecd2_det" then do:

      create ecd2det.
      assign
         ecd2_nbr  = key_fld[2]
         ecd2_routing  = key_fld[3]
         ecd2_op = integer(key_fld[4]).

      import stream ecstream ecd2det
         except ecd2det.ecd2_nbr
                ecd2det.ecd2_routing
                ecd2det.ecd2_op.

      create qadwkfl.
      import stream ecstream qadwkfl.

   end.

   else if key_fld[1] = "type:ecd3_det" then do:

      create ecd3det.
      assign
         ecd3_nbr  = key_fld[2]
         ecd3_cmtindx  = integer(key_fld[3]).

      import stream ecstream ecd3det except
         ecd3det.ecd3_nbr
         ecd3det.ecd3_cmtindx.

   end.

   else if key_fld[1] = "type:ecd4_det" then do:

      create ecd4det.
      assign
         ecd4_nbr  = key_fld[2]
         ecd4_cmtindx  = integer(key_fld[3]).

      import stream ecstream ecd4det except
         ecd4det.ecd4_nbr
         ecd4det.ecd4_cmtindx.

   end.

   else if key_fld[1] = "type:rsu_mstr" then do:

      create rsumstr.
      assign
         rsu_doc_nbr = key_fld[2]
         rsu_index = integer(key_fld[3]).

      import stream ecstream rsumstr except
         rsumstr.rsu_doc_nbr
         rsumstr.rsu_index.

   end.

   else if key_fld[1] = "type:rsud_det" then do:

      create rsuddet.
      assign
         rsud_group = key_fld[2]
         rsud_index = integer(key_fld[3]).

      import stream ecstream rsuddet except
         rsuddet.rsud_group
         rsuddet.rsud_index.
   end.

   else if key_fld[1] = "type:ecd_det" then do:

      create ecddet.
      assign
         ecd_nbr  = key_fld[2]
         ecd_part  = key_fld[3].

      if key_fld[4] = "yes" then
         ecd_new = yes.
      else
         ecd_new = no.

      import stream ecstream ecddet except
         ecddet.ecd_nbr
         ecddet.ecd_part
         ecddet.ecd_new.
   end.

   else if key_fld[1] = "type:cmt_det" then do:

      create cmtdet.
      assign
         cmtdet.cmt_indx = integer(key_fld[2])
         cmtdet.cmt_seq  = integer(key_fld[3]).

      import stream ecstream cmtdet except
         cmtdet.cmt_indx
         cmtdet.cmt_seq.

   end.

end.

input stream ecstream close.
